package com.twu.biblioteca;

public class Book {

    private BookInformation bookInfo;
    private boolean reservationStatus;

    public Book(BookInformation bookInformation, boolean bookReservationStatus){
        bookInfo = bookInformation;
        reservationStatus = bookReservationStatus;
    }

    public BookInformation getBookInfo() {
        return bookInfo;
    }

    public boolean isBookReserved() {
        return reservationStatus;
    }

    public String ReserveBook() {
        if(isBookReserved())
            return "Sorry we don't have that book yet.";
        else
        {
            reservationStatus = true;
            return "Thank you! Enjoy the book.";
        }
    }

    @Override
    public boolean equals(Object objectToCompare){
        if(!(objectToCompare instanceof Book))
            return false;

        Book bookToCompare = (Book) objectToCompare;
        if (bookInfo.equals(bookToCompare.getBookInfo()) && reservationStatus == bookToCompare.isBookReserved())
            return true;

        return false;
    }

}
